package com.qinggeng.project.api.controller;

import com.qinggeng.common.utils.poi.ExcelUtil;
import com.qinggeng.framework.aspectj.lang.annotation.Log;
import com.qinggeng.framework.aspectj.lang.enums.BusinessType;
import com.qinggeng.framework.web.controller.BaseController;
import com.qinggeng.framework.web.domain.AjaxResult;
import com.qinggeng.framework.web.page.TableDataInfo;
import com.qinggeng.project.api.dto.JobDliveryDTO;
import com.qinggeng.project.api.security.annotation.LoginRequired;
import com.qinggeng.project.api.security.utils.ApiUtils;
import com.qinggeng.project.system.domain.JobDlivery;
import com.qinggeng.project.system.domain.JobInfoBrowse;
import com.qinggeng.project.system.service.IJobInfoBrowseService;
import com.qinggeng.project.system.service.JobDliveryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 招聘信息浏览记录Controller
 *
 * @author smallfish
 * @date 2020-12-24
 */
@RestController
@RequestMapping("/api/jobDlivery")
@CrossOrigin("*")
public class ApiJobDliveryController extends BaseController
{
    @Autowired
    private JobDliveryService jobDliveryService;

    /**
     * 简历列表
     */
    @GetMapping("/list")
    @LoginRequired(must = false,role = ApiUtils.DEFAULT_ROLE_USER)
    public TableDataInfo list(JobDlivery  jobDlivery)
    {
        startPage();
        List<JobDlivery> list = jobDliveryService.listJobDliveryByPositionUserId();
        return getDataTable(list);
    }

    /**
     * 单个信息
     */
    @GetMapping("/get")
    @LoginRequired(must = false,role = ApiUtils.DEFAULT_ROLE_USER)
    public AjaxResult get(JobDlivery  jobDlivery)
    {
        JobDlivery dlivery = jobDliveryService.getJobDliveryById(jobDlivery);
        return AjaxResult.success(dlivery);
    }


    /**
     * 用户投递
     */
    @PostMapping("/insertJobUserDlivery")
    @LoginRequired(must = false,role = ApiUtils.DEFAULT_ROLE_USER)
    public AjaxResult insertJobUserDlivery(JobDlivery  jobDlivery)
    {
        boolean bl=jobDliveryService.insertJobUserDlivery(jobDlivery);
        if (bl ==false){
            return AjaxResult.error("添加失败");
        }
        return AjaxResult.success();
    }

    /**
     * 公司邀请
     */
    @PostMapping("/insertCompanyDlivery")
   @LoginRequired(must = false,role = ApiUtils.DEFAULT_ROLE_USER)
    public AjaxResult insertCompanyDlivery(JobDliveryDTO jobDlivery)
    {
        boolean bl=jobDliveryService.insertCompanyDlivery(jobDlivery);
        if (bl ==false){
            return AjaxResult.error("添加失败");
        }
        return AjaxResult.success();
    }


}
